<extend name="Layout:layout_grid" />
<block name="head_after">
    <style type="text/css">        
        main { padding:0 10px;}
        main h3 { font-size:16px; font-weight: bold; color:#555; margin-bottom:5px;}
        .title { color:#F00; font-weight: bold; padding:5px; border-bottom:dotted 1px #F60;}
        .log { border-bottom:dotted 1px #CCC; padding:3px;}
        .log-types { margin:5px 0;}
        .log-types strong { padding:5px 0px; display:block; font-weight: bold; color:#555;}
        .log-types li { display:inline-block; list-style: none; padding:3px 10px; border-left:solid 1px #CCC;}
        .log-types li:first-child { border:none;}
        .log-types a, .flags a:active { color:#00C;}
        .log-types li.active { color:#F00; font-weight:bold; background-color:#009500;}
        .log-types li.active a { color:#FFF;}
        .log-types a:hover { color:#F00;}
        #chk-hidden { vertical-align: middle; margin-right:5px;}
        .content { max-height: 600px; overflow-y: auto; margin:5px 0px;}
    </style>
</block>
<block name="body_main">
    <div class="plog">        
        <div class="grid-container grid-parent page-header">
            <div class="grid-20">
                <form>
                    项目：<Sohtml:select name="dir" items="{$data.dirs}" value="{$data.cur_dir}" valuefield="name" textfield="name" />
                    <button type="submit" class="xsui-btn ui-state-default">获取日志文件</button>
                </form>
            </div>
            <div class="grid-60">
                <if condition="$data['cur_dir']">
                    <select name="file">
                        <foreach name="data['files']" item="vo" start="1">
                            <if condition="$data['cur_file'] eq $key">
                                <option value="{$vo.name}" selected="selected">{$key}.{$vo.name} ({:format_bytes($vo['size'])})</option>
                                <else/>
                                <option value="{$vo.name}">{$key}.{$vo.name} ({:format_bytes($vo['size'])})</option>
                            </if>
                        </foreach>
                    </select>
                    {$data['cur_dir_size']}
                    <input type="hidden" name="dir" value="{$data['cur_dir']}" />
                    <input type="hidden" name="action" value="" />
                    <button type="submit" class="xsui-btn ui-state-default">立即分析</button>
                    <button type="button" class="xsui-btn ui-state-default" id="lnk-download"><i class="fa fa-download"></i>下载</button>
                </if>
                <button class="xsui-btn ui-state-default lnk-refresh"><i class="fa fa-refresh"></i>刷新</button>
            </div>
        </div>
    </div>
    <main>
        <h3>{$data.title}</h3>
        <if condition="$data['cur_file']">
            <div class="log-types">
                <strong>日志类型：</strong>
                <ul>
                    <foreach name="data['typeset']" item="vo">
                        <if condition="$data['cur_type'] eq $key">
                            <li class="active"><a href="{:AddonU('index','dir='.$data['cur_dir'].'&file='.urlencode($data['cur_file']).'&type='.$key)}" title="{$vo}">{$key}</a></li>
                            <else/>
                            <li><a href="{:AddonU('index','dir='.$data['cur_dir'].'&file='.urlencode($data['cur_file']).'&type='.$key)}" title="{$vo}">{$key}</a></li>
                        </if>
                    </foreach>
                </ul>
            </div>
            <table cellpadding="0" cellspacing="0">
                <tr><td style="width:20px"><input type="checkbox" id="chk-hidden" /></td><td>隐藏无效内容</td></tr>
            </table>
            {:afn_write_log($data['log_path'],$data['cur_type'])}
        </if>
    </main>
    <div class="clear"></div>
</div>
</block>
<block name="body_after">    
    <script type="text/javascript">
        var gridPage = GridPage.newInstance();
        $(function () {
            // 网页页面视图初始化 2015-10-17 SoChishun Added.
            gridPage.ui_init();
            // 显示或隐藏无效记录 2015-11-25 SoChishun Added.
            $('#chk-hidden').change(function () {
                if ($(this).prop('checked')) {
                    $('.content .section').hide();
                    $('.content .log').parent().show();
                } else {
                    $('.content .section').show();
                }
            })
            $('#lnk-download').click(function () {
                $('input[name="action"]').val('download');
            });
        });
    </script>
</block>